<extend name="layout/admin" />
<block name="title"><title>商品添加</title></block>
<block name="content">
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
	<div class="graphs">
	    <div class="xs">
	  	    <h3>商品添加</h3>
	  	    <div class="tab-content">
				<div class="tab-pane active" id="horizontal-form">
					<form class="form-horizontal" action="__URL__/insert"  enctype="multipart/form-data" method="post">
						<div class="form-group">
							<label for="selector1" class="col-sm-2 control-label">商品类别</label>
							<div class="col-sm-8">
								<select name="pid" id="selector1" class="form-control1">
									<option value="0">请选择:</option>
									<foreach name="res" item="vo">
										<option value="{$vo.id}">&nbsp;{$vo.name}</option>
									</foreach>
								</select>
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">商品名称</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="请输入商品名称" type="text" name="gname">
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">产品编号</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="请输入商品编号" type="text" name="gid">
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">产品规格</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="请输入商品规格" type="text" name="size">
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">商品正价</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="请输入商品正价" type="text" name="price">
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">商品优惠价</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="请输入商品优惠价" type="text" name="fprice">
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">积分价</label>
							<div class="col-sm-8">
								<input class="form-control1" disabled id="focusedinput" placeholder="请输入商品优惠价" type="text" name="pv">
							</div>
						</div>
						<div class="form-group">
					        <label for="txtarea1" class="col-sm-2 control-label">产品图片</label>
							<div class="col-sm-8">
						        <input name="pic" type="file" multiple><p class="help-block">可上传多张商品图片!</p>
					        </div>
					    </div>
						<div class="form-group">
							<label for="txtarea1" class="col-sm-2 control-label">产品描述</label>
							<div class="col-sm-8">
								<script id="editor1" name="desc" type="text/plain" style="width:700px;height:100px;"></script>
							</div>
						</div>

						<div class="form-group">
							<label for="txtarea1" class="col-sm-2 control-label">产品特点</label>
							<div class="col-sm-8">
								<script id="editor2" name="special" type="text/plain" style="width:700px;height:100px;"></script>
							</div>
						</div>
						<div class="form-group">
							<label for="txtarea1" class="col-sm-2 control-label">注意事项</label>
							<div class="col-sm-8">
								<script id="editor3" name="notice" type="text/plain" style="width:700px;height:100px;"></script>
							</div>
						</div>
					    <div class="form-group">
							<label for="radio" class="col-sm-2 control-label">商品状态</label>
							<div class="col-sm-8">
								<div class="radio-inline"><label><input type="radio" name="status" value="0" checked> 新品</label></div>
								<div class="radio-inline"><label><input type="radio" name="status" value="1"> 上架</label></div>
								<div class="radio-inline"><label><input type="radio" name="status" value="2"> 下架</label></div>
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">库存</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="请输入商品库存" type="text" name="repertory">
							</div>
						</div>
						<div class="form-group">
							<label for="focusedinput" class="col-sm-2 control-label">销量</label>
							<div class="col-sm-8">
								<input class="form-control1" id="focusedinput" placeholder="销量" type="text" name="sales">
							</div>
						</div>
					    <div class="form-group">
					    	<div class="col-sm-8 col-sm-offset-2">
					    		<button class="btn btn-success" type="submit">提交</button>
					    		<button class="btn btn-warning" type="reset">重置</button>
					    	</div>
					    </div>
					</form>
				</div>
			</div>
	  	</div>
	</div>
<script type="text/javascript">
$(function(){
	var price_i = 0;
	var fprice_i = 0;
	 $('input[name=price]').keyup(function(){
	 	var price = $(this).val();
	 	price_i = parseFloat(price);
	 }).blur(function(){
	 	var aaa = price_i - fprice_i;
	 	if(aaa<0){
			alert('商品正价不能小于优惠价');
			$('input[name=pv]').val('');
		}else{
			$('input[name=pv]').val(aaa);
		}
	 });
	 $('input[name=fprice]').keyup(function(){
	 	var fprice = $(this).val();
	 	fprice_i = parseFloat(fprice);
	 }).blur(function(){
	 	var aaa = price_i - fprice_i;
		if(aaa<0){
			alert('商品正价不能小于优惠价');
			$('input[name=pv]').val('');
		}else{
			$('input[name=pv]').val(aaa);
		}
	});

     var ue1 = UE.getEditor('editor1');
     var ue2 = UE.getEditor('editor2');
     var ue3 = UE.getEditor('editor3');
});
</script>
</block>